﻿using System;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.InterceptionExtension;


namespace WinnerCMS.BLL
{
    /// <summary>
    /// 缓存
    /// </summary>
    [AttributeUsage(AttributeTargets.Method)]
    public class CacheAttribute : HandlerAttribute
    {
        /// <summary>
        /// 缓存构造函数
        /// </summary>
        public CacheAttribute()
        {
        }
        /// <summary>
        /// 缓存构造函数
        /// </summary>
        /// <param name="key"></param>
        public CacheAttribute(string key)
        {
            this.Key = key;
            this.Order = 1;
        }
   
        /// <summary>
        /// 缓存标识
        /// </summary>
        public string Key { get; set; }


        public override ICallHandler CreateHandler(IUnityContainer container)
        {
            //创建具体Call Handler，并调用
            CacheHandler handler = new CacheHandler(this.Key)
            {
                Order = this.Order
            };
            return handler;
        }
    }
}